/**
 * $Revision: 1.0 $
 * $Author: Eric Yang $
 * $Date: Sep 2, 2009 8:53:07 PM $
 *
 * Author: Eric Yang
 * Date  : Sep 2, 2009 8:53:07 PM
 *
 */
package com.gooex.domain.base.emun;

/**
 * 订单状态
 * 
 * @author Eric Yang
 * @version 1.0
 */
public enum OrderStatus {

	/** saved,not begin to invite */
	SAVED(0, "SAVED"),

	/** inviting 邀请中 */
	INVITING(1, "INVITING"),

	/** QUOTING 报价中 */
	QUOTING(2, "QUOTING"),

	/** voting 投票中 */
	VOTING(3, "VOTING"),

	/** confirmed 已确认 */
	CONFIRMED(4, "CONFIRMED"),

	/** closed 已关闭 */
	CLOSED(5, "CLOSED"),

	/** canceled 已取消 */
	CANCELED(6, "CANCELED");

	/**
	 * 数据库中保存的值
	 */
	private int code;

	private String desc;

	public String getDesc() {
		return desc;
	}

	private OrderStatus(int code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public int getCode() {
		return this.code;
	}

	public boolean equals(OrderStatus status) {
		return this.getCode() == status.getCode();
	}

	public boolean equals(int code) {
		return this.getCode() == code;
	}

	@Override
	public String toString() {
		return this.desc;
	}

	public static OrderStatus getObj(int code) {
		for (OrderStatus item : values()) {
			if (item.getCode() == code) {
				return item;
			}
		}

		return null;
	}

	public boolean isSaved() {
		return SAVED.equals(this);
	}

	public boolean isInviting() {
		return INVITING.equals(this);
	}

	public boolean isQuoting() {
		return QUOTING.equals(this);
	}

	public boolean isVoting() {
		return VOTING.equals(this);
	}

	public boolean isConfirmed() {
		return CONFIRMED.equals(this);
	}

	public boolean isCanceled() {
		return CANCELED.equals(this);
	}

	public boolean isClosed() {
		return CLOSED.equals(this);
	}
}
